package com.bookstore.Domain;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @author 未来
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("书籍实体类")
@Component
public class Book {

    @TableId(type = IdType.AUTO)
    private int id;
    @ApiModelProperty("书籍名称")
    private String name;
    @ApiModelProperty("书籍作者")
    private String author;
    @ApiModelProperty("书籍名称分类")
    private int categoryId;
    @ApiModelProperty("书籍出版时间")
    private Timestamp time;
    @ApiModelProperty("书本单价")
    private double price;
    @ApiModelProperty("书本库存")
    private int number;
    @ApiModelProperty("书籍图片地址")
    private String image;
    @ApiModelProperty("书籍描述")
    private String description;

    /**
     * 设置自动填充：sql语句
     */
    @TableField(fill = FieldFill.INSERT)
    private Date gmt_create;

    /**
     * 修改时间：修改数据的时候,看得到，映射不会生效***
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date gmt_modified;

    /**
     * 逻辑删除： UPDATE user SET deleted=1 WHERE name = ? AND deleted=0
     * 查询的时候会自动过滤删除过的字段***
     */
    @TableLogic
    private Integer deleted;

}
